<template>
  <router-view v-slot="{ Component }">
    <keep-alive exclude="DetailView">
      <component :is="Component" />
    </keep-alive>
  </router-view>

  <van-tabbar
    placeholder
    v-model="active"
    active-color="#ee0a24"
    route
    v-show="$route.meta.tabbarShow"
  >
    <van-tabbar-item icon="home-o" replace to="/">首页</van-tabbar-item>
    <van-tabbar-item icon="search" replace to="/cate">分类</van-tabbar-item>
    <van-tabbar-item icon="pending-payment" replace to="/cart" :badge="countNum"
      >购物车</van-tabbar-item
    >
    <van-tabbar-item icon="setting-o" replace to="/my">我的</van-tabbar-item>
  </van-tabbar>

  ssd
</template>
<script setup>
import { ref } from "vue";
import { getCartList, countNum } from "./store/cart";
import { getToken } from "./utils/token";

//进入网站-判断是否的登录，如果登录获取购物车列表数据，更新全局状态
if (getToken()) {
  getCartList();
}

const active = ref(0);
</script>
<style lang="css" scoped></style>
